//
//  CATextLayer.swift
//  Documentation
//
//  Created by Toj on 3/8/24.
//
// CATextLayer是专用的文本显示图层，有和UILaber一样的显示功能，
// 只是CATextLayer的文本渲染功能更加强大，效率更高

https://www.jianshu.com/p/6817de4452db

public struct CATextLayerTruncationMode : Hashable, Equatable, RawRepresentable, @unchecked Sendable {

    public init(rawValue: String)
}
public struct CATextLayerAlignmentMode : Hashable, Equatable, RawRepresentable, @unchecked Sendable {

    public init(rawValue: String)
}

@available(iOS 2.0, *)
open class CATextLayer : CALayer {

    
    /* The text to be rendered, should be either an NSString or an
     * NSAttributedString. Defaults to nil. */
    
    open var string: Any?

    
    /* The font to use, currently may be either a CTFontRef (toll-free
     * bridged from UIFont), a CGFontRef, or a string naming the font.
     * Defaults to the Helvetica font. Only used when the `string' property
     * is not an NSAttributedString. */
    
    open var font: CFTypeRef?

    
    /* The font size. Defaults to 36. Only used when the `string' property
     * is not an NSAttributedString. Animatable (Mac OS X 10.6 and later.) */
    
    open var fontSize: CGFloat

    
    /* The color object used to draw the text. Defaults to opaque white.
     * Only used when the `string' property is not an NSAttributedString.
     * Animatable (Mac OS X 10.6 and later.) */
    
    open var foregroundColor: CGColor?

    
    /* When true the string is wrapped to fit within the layer bounds.
     * Defaults to NO.*/
    
    open var isWrapped: Bool

    
    /* Describes how the string is truncated to fit within the layer
     * bounds. The possible options are `none', `start', `middle' and
     * `end'. Defaults to `none'. */
    
    open var truncationMode: CATextLayerTruncationMode

    
    /* Describes how individual lines of text are aligned within the layer
     * bounds. The possible options are `natural', `left', `right',
     * `center' and `justified'. Defaults to `natural'. */
    
    open var alignmentMode: CATextLayerAlignmentMode

    
    /* Sets allowsFontSubpixelQuantization parameter of CGContextRef
     * passed to the -drawInContext: method. Defaults to NO. */
    
    open var allowsFontSubpixelQuantization: Bool
}
extension CATextLayerTruncationMode {

    
    @available(iOS 3.2, *)
    public static let none: CATextLayerTruncationMode

    
    @available(iOS 3.2, *)
    public static let start: CATextLayerTruncationMode

    
    @available(iOS 3.2, *)
    public static let end: CATextLayerTruncationMode

    
    @available(iOS 3.2, *)
    public static let middle: CATextLayerTruncationMode
}
extension CATextLayerAlignmentMode {

    
    @available(iOS 3.2, *)
    public static let natural: CATextLayerAlignmentMode

    
    @available(iOS 3.2, *)
    public static let left: CATextLayerAlignmentMode

    
    @available(iOS 3.2, *)
    public static let right: CATextLayerAlignmentMode

    
    @available(iOS 3.2, *)
    public static let center: CATextLayerAlignmentMode

    
    @available(iOS 3.2, *)
    public static let justified: CATextLayerAlignmentMode
}
